package br.com.translog.gui.fornecimento;

//import br.com.translog.controlador.ControladorFornecimento;
import br.com.translog.gui.funcionario.*;
import br.com.translog.fachada.FachadaTranslog;
import br.com.translog.gui.outro.FrmMenuPrincipal;
import br.com.translog.modelo.Fornecimento;
import br.com.translog.modelo.Funcionario;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;

public class FrmFornecimentoConsultar extends javax.swing.JFrame {

    /**
     * Creates new form FrmFuncionarioCadastrar
     */
    public FrmFornecimentoConsultar() {
        initComponents();
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form. WARNING: Do NOT
     * modify this code. The content of this method is always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlFuncionarioConsultar = new javax.swing.JPanel();
        txtMatricula1 = new javax.swing.JTextField();
        btnAtualizar1 = new javax.swing.JButton();
        txtMatricula3 = new javax.swing.JTextField();
        lblAlterarFuncionario = new javax.swing.JLabel();
        lblMatricula = new javax.swing.JLabel();
        lblFuncionario = new javax.swing.JLabel();
        btnCancelar = new javax.swing.JButton();
        lblFuncionario2 = new javax.swing.JLabel();
        txtMatricula = new javax.swing.JTextField();
        lblFuncionario3 = new javax.swing.JLabel();
        txtMatricula4 = new javax.swing.JTextField();
        lblFuncionario4 = new javax.swing.JLabel();
        txtMatricula2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("TransLog - Sistema de Entrega de Transportadora - Cadastro de Funcionário");
        setMaximumSize(null);
        setMinimumSize(null);
        setName("frmFuncionarioCadastrar"); // NOI18N
        setResizable(false);

        pnlFuncionarioConsultar.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        pnlFuncionarioConsultar.setMaximumSize(new java.awt.Dimension(956, 315));
        pnlFuncionarioConsultar.setMinimumSize(new java.awt.Dimension(956, 315));

        btnAtualizar1.setText("Pesquisar");
        btnAtualizar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAtualizar1ActionPerformed(evt);
            }
        });

        lblAlterarFuncionario.setFont(new java.awt.Font("Tahoma", 1, 15)); // NOI18N
        lblAlterarFuncionario.setText("CONSULTAR FORNECIMENTO");
        lblAlterarFuncionario.setName(""); // NOI18N

        lblMatricula.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblMatricula.setText("Data de Fornecimento");

        lblFuncionario.setText("Quantidade");

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        lblFuncionario2.setText("Cod. Fornecedor");

        lblFuncionario3.setText("Cod. Produto");

        lblFuncionario4.setText("Número de Fornecimento");

        javax.swing.GroupLayout pnlFuncionarioConsultarLayout = new javax.swing.GroupLayout(pnlFuncionarioConsultar);
        pnlFuncionarioConsultar.setLayout(pnlFuncionarioConsultarLayout);
        pnlFuncionarioConsultarLayout.setHorizontalGroup(
            pnlFuncionarioConsultarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFuncionarioConsultarLayout.createSequentialGroup()
                .addGroup(pnlFuncionarioConsultarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblFuncionario4)
                    .addComponent(lblFuncionario2)
                    .addComponent(lblFuncionario3))
                .addGap(18, 18, 18)
                .addGroup(pnlFuncionarioConsultarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlFuncionarioConsultarLayout.createSequentialGroup()
                        .addComponent(txtMatricula4, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lblFuncionario)
                        .addGap(18, 18, 18)
                        .addComponent(txtMatricula3, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlFuncionarioConsultarLayout.createSequentialGroup()
                        .addComponent(txtMatricula2, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnAtualizar1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlFuncionarioConsultarLayout.createSequentialGroup()
                        .addComponent(txtMatricula1, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lblMatricula)
                        .addGap(18, 18, 18)
                        .addComponent(txtMatricula, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(pnlFuncionarioConsultarLayout.createSequentialGroup()
                .addGroup(pnlFuncionarioConsultarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlFuncionarioConsultarLayout.createSequentialGroup()
                        .addGap(219, 219, 219)
                        .addComponent(lblAlterarFuncionario))
                    .addGroup(pnlFuncionarioConsultarLayout.createSequentialGroup()
                        .addGap(236, 236, 236)
                        .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlFuncionarioConsultarLayout.setVerticalGroup(
            pnlFuncionarioConsultarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFuncionarioConsultarLayout.createSequentialGroup()
                .addComponent(lblAlterarFuncionario)
                .addGap(18, 18, 18)
                .addGroup(pnlFuncionarioConsultarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFuncionario4)
                    .addComponent(txtMatricula2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAtualizar1))
                .addGap(18, 18, 18)
                .addGroup(pnlFuncionarioConsultarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFuncionario2)
                    .addComponent(txtMatricula1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblMatricula)
                    .addComponent(txtMatricula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlFuncionarioConsultarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFuncionario3)
                    .addComponent(txtMatricula4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblFuncionario)
                    .addComponent(txtMatricula3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(btnCancelar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlFuncionarioConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlFuncionarioConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAtualizar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAtualizar1ActionPerformed
        // TODO add your handling code here:
        
        
                
                //Instanciando os objetos que serao utilizados...
        //Fornecimento fornecimento;
/*
        try {
            //Verifica se o campo de pesquisa nao esta em "branco"...
            if (!txtMatricula2.getText().equals("")) {
                Fornecimento  fornecimento2 = new Fornecimento();
                fornecimento2.setNumeroSolicitacao(Integer.parseInt(txtMatricula2.getText()));
                fornecimento = ControladorFornecimento.getInstance().consultaFornecimento(fornecimento2);
                if (fornecimento == null) {
                    JOptionPane.showMessageDialog(null, "Fornecimento não Encontrado!");
                } else {
                    //Convertendo as datas para exibicao no JTextField...
                    String data = new SimpleDateFormat("dd/MM/yyyy").format(fornecimento.getData());
                    txtMatricula.setText(String.valueOf(data));
                    txtMatricula1.setText(String.valueOf(fornecimento.getFornecedor().getCodigo()));
                    txtMatricula4.setText(String.valueOf(fornecimento.getProduto().getCodigo()));
                    txtMatricula3.setText(String.valueOf(fornecimento.getQuantidade()));
                }

            } else {
                JOptionPane.showMessageDialog(null, "Dados Obrigatórios não Informados!");
            }

        } catch (Exception e) {
        } */
    }//GEN-LAST:event_btnAtualizar1ActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed

        new FrmMenuPrincipal().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_btnCancelarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmFuncionarioConsultar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmFuncionarioConsultar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmFuncionarioConsultar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmFuncionarioConsultar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new FrmFuncionarioConsultar().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAtualizar1;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JLabel lblAlterarFuncionario;
    private javax.swing.JLabel lblFuncionario;
    private javax.swing.JLabel lblFuncionario2;
    private javax.swing.JLabel lblFuncionario3;
    private javax.swing.JLabel lblFuncionario4;
    private javax.swing.JLabel lblMatricula;
    private javax.swing.JPanel pnlFuncionarioConsultar;
    private javax.swing.JTextField txtMatricula;
    private javax.swing.JTextField txtMatricula1;
    private javax.swing.JTextField txtMatricula2;
    private javax.swing.JTextField txtMatricula3;
    private javax.swing.JTextField txtMatricula4;
    // End of variables declaration//GEN-END:variables
}
